<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand"><img src="/imgs/logo.png"></a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li v-if="hasPermission" :class="{active:activeIndex==0}">
                    <a href="/department">部门管理 </a>
                </li>
                <li v-if="hasPermission" :class="{active:activeIndex==1}">
                    <a href="/position">职位管理</a>
                </li>
                <li v-if="hasPermission" :class="{active:activeIndex==2}">
                    <a href="/staff">职工管理</a>
                </li>
                <li v-if="!no_score" :class="{active:activeIndex==3}">
                    <a href="/years">年度评分</a>
                </li>
                <li v-if="hasPermission&&!no_score" :class="{active:activeIndex==4}">
                    <a href="/count">评分统计</a>
                </li>
                <li v-if="!no_score" :class="{active:activeIndex==5}">
                    <a href="/grade">我的评分</a>
                </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li v-if="user">
                    <a href="#" class="username"><span class="glyphicon glyphicon-user" aria-hidden="true"></span>@{{user.name}}</a>
                </li>
                <li class="dropdown" :class="{active:activeIndex==6}">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">设置 <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <!--<li v-if="user.id==1"><a @click="createYear">开启考核</a></li>-->
                        <li v-if="user.id==1"><a onclick="createYear()">开启考核</a></li>
                        <!--<li v-if="user.id==1"><a @click="createScore">评分结算</a></li>-->
                        <li v-if="user.id==1"><a onclick="createScore()">评分结算</a></li>
                        <li>
                            <a href="/update_pass">更改密码</a>
                        </li>
                        <li>
                            {{-- <a href="/config">系统配置</a> --}}
                        </li>
                        <li role="separator" class="divider"></li>
                        <li>
                            <a href="javascript:void(0)" @click="logout">注销登录</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container-fluid -->
</nav>
<style>
    .navbar-nav>li{
        cursor: pointer;
    }
</style>

<script>
    function createYear() {
        var tempe = prompt("请确认是否需要开启今年的评分考核？确认请输入开启密码：");
        if(tempe=="hengsukejizzw"){
            $.ajax({
                type: "GET",
                async:false,//同步
                url: '{{route("apo_create_year")}}',
                data: {},
                contentType: "application/x-www-form-urlencoded;charset=UTF-8",
                dataType: "json",
                success: function(data, textStatus) {

                },
            });
        }else{
            alert("密码错误")
        }
    }

    function createScore() {
        var tempe = prompt("请确认是否需要开启评分结算？确认请输入开启密码：");
        if(tempe=="hengsukejizzw"){
            $.ajax({
                type: "GET",
                async:false,//同步
                url: '{{route("api_create_year")}}',
                data: {},
                contentType: "application/x-www-form-urlencoded;charset=UTF-8",
                dataType: "json",
                success: function(data, textStatus) {
                    alert(data.responseJSON.message);
                },
                error: function (data) {
                    alert(data.responseJSON.message);
                }
            });
        }else{
            alert("密码错误")
        }
    }
</script>
